﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Drawing.Drawing2D;

namespace FourKill.Engine
{
    public class Cloud : IPaintable
    {
        private static Cloud _instance;
        public static Cloud Instance { get { _instance = _instance ?? new Cloud(); return _instance; } }

        public void Paint(IPaintableContext context)
        {
            if (context.GameObject.LocationRelativeToCamera == null)
                context.GameObject.UpdateLocation(context);
            var location = context.GameObject.LocationRelativeToCamera;

            if (location.IsVisible)
            {
                try
                {
                    using (SolidBrush sb = new SolidBrush( context.GameObject.Color))
                    {
                        context.FrontLayer.FillPath(sb, Utility.CreateRoundedRectanglePath(location.ObjectRectangle, (location.ObjectRectangle.Height > 4 ? location.ObjectRectangle.Height / 4 : 1)));
                    }
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine("***********************************");
                    System.Diagnostics.Debug.WriteLine(ex.Message + "\r\n" + ex.StackTrace);
                    System.Diagnostics.Debugger.Break();
                }
            }
        }
    }
}
